package com.zxt.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zxt.convert.SysRoleConvert;
import com.zxt.dto.SysRoleDTO;
import com.zxt.dto.SysRoleQueryDTO;
import com.zxt.manager.SysRoleManager;
import com.zxt.manager.SysUserManager;
import com.zxt.model.SysRole;
import com.zxt.query.QueryResultVO;
import com.zxt.service.ISysRoleService;
import com.zxt.vo.SysRoleVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


/**
 * 业务逻辑层-角色信息实现类
 */
@Slf4j
@Service("sysRoleService")
@AllArgsConstructor
public class SysRoleServiceImpl implements ISysRoleService {

    private final SysRoleManager sysRoleManager;
    private final SysUserManager sysUserManager;

    @Override
    public QueryResultVO<SysRoleVO> query(SysRoleQueryDTO dto) {
        IPage<SysRole> page = sysRoleManager.query(dto);
        QueryResultVO<SysRoleVO> queryResultVO = QueryResultVO.pageToQueryResult(page,SysRoleVO.class);
        queryResultVO.setRecords(SysRoleConvert.INSTANCE.convertList(page.getRecords()));
        return queryResultVO;
    }

    @Override
    public void createSysRole(SysRoleDTO sysRoleDTO) {
        SysRole target = new SysRole();
        org.springframework.beans.BeanUtils.copyProperties(sysRoleDTO, target);
        sysRoleManager.save(target);
    }

    @Override
    public void updateSysRole(SysRoleDTO sysRoleDTO) {

    }
}
